<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
<?php
    // 连接数据库
    require_once("conn.php");
    // 账号
    $userid = $_POST['user'];
    // 密码
    $password = $_POST['password'];
    // 查询数据库
    $qry = mysqli_query($con,"select * from admin where userid = '$userid' ");
    $row = mysqli_fetch_array($qry,MYSQLI_ASSOC);

    // 验证用户
    if($userid == $row['userid'] && $password == $row['password'] && $userid != null && $password != null){
        session_start();
        $_SESSION['login'] = $userid;
        header('location:list.php');
        echo '登录成功';
    } else {
        header('refresh:1; url = /test/index.php');
        echo '账号或密码错误';
    }
?>
</body>
</html>